#include "ElementSpikes.h"

ElementSpikes::ElementSpikes(vector3<int> pos)
{
    type=SPIKES;
    geometry = AABB(vector3<float>(0,0,0),vector3<float>(1,1,1));
    translate(pos.cast<float>());
    damage=5;
    activated=false;
    isCollidable=false;
    aniObj.stop();
}

void ElementSpikes::invokeCollisionEvent(Character* ch){
    if(!activated)
    ch->damage(damage);
}

void ElementSpikes::invokeActivateEvent(){

}

void ElementSpikes::invokeUpdateEvent(Character *c){

}

void ElementSpikes::activate(){
    if(activated)return;

    activated=true;

    aniObj.playForward();
    aniObj.reset();
}

void ElementSpikes::deactivate(){
    if(!activated)return;

    activated=false;

    aniObj.playReverse();
    aniObj.reset();

}

void ElementSpikes::render(){
    glPushMatrix();
    glTranslatef(s.position.x,s.position.y,s.position.z);
    aniObj.render();
    glPopMatrix();
}
